home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / XAMPP 1.4.14 / xampp-win32-1.4.14-installer.exe / xampp / php / pear / adodb / tests / testmssql.php < prev    next >
PHP Script  |  2005-04-02  |  2KB  |  76 lines

  1. <?php
  2.  
  3. /** 
  4.  * @version V4.50 6 July 2004 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
  5.  * Released under both BSD license and Lesser GPL library license. 
  6.  * Whenever there is any discrepancy between the two licenses, 
  7.  * the BSD license will take precedence. 
  8.  *
  9.  * Set tabs to 4 for best viewing.
  10.  * 
  11.  * Latest version is available at http://php.weblogs.com
  12.  *
  13.  * Test GetUpdateSQL and GetInsertSQL.
  14.  */
  15.  
  16. error_reporting(E_ALL);
  17.  
  18.  
  19. include('../adodb.inc.php');
  20. include('../tohtml.inc.php');
  21.  
  22. //==========================
  23. // This code tests an insert
  24.  
  25.  
  26.  
  27. $conn = &ADONewConnection("mssql");  // create a connection
  28. $conn->Connect('127.0.0.1','adodb','natsoft','northwind') or die('Fail');
  29.  
  30. $conn->debug =1;
  31. $query = 'select * from products';
  32. $conn->SetFetchMode(ADODB_FETCH_ASSOC);
  33. $rs = $conn->Execute($query);
  34. echo "<pre>";
  35. while( !$rs->EOF ) {
  36.     $output[] = $rs->fields;
  37.     var_dump($rs->fields);
  38.     $rs->MoveNext();
  39.     print "<p>";
  40. }
  41. die();
  42.  
  43.  
  44. $p = $conn->Prepare('insert into products (productname,unitprice,dcreated) values (?,?,?)');
  45. echo "<pre>";
  46. print_r($p);
  47.  
  48. $conn->debug=1;
  49. $conn->Execute($p,array('John'.rand(),33.3,$conn->DBDate(time())));
  50.  
  51. $p = $conn->Prepare('select * from products where productname like ?');
  52. $arr = $conn->getarray($p,array('V%'));
  53. print_r($arr);
  54. die();
  55.  
  56. //$conn = &ADONewConnection("mssql");
  57. //$conn->Connect('mangrove','sa','natsoft','ai');
  58.  
  59. //$conn->Connect('mangrove','sa','natsoft','ai');
  60. $conn->debug=1;
  61. $conn->Execute('delete from blobtest');
  62.  
  63. $conn->Execute('insert into blobtest (id) values(1)');
  64. $conn->UpdateBlobFile('blobtest','b1','../cute_icons_for_site/adodb.gif','id=1');
  65. $rs = $conn->Execute('select b1 from blobtest where id=1');
  66.  
  67. $output = "c:\\temp\\test_out-".date('H-i-s').".gif"; 
  68. print "Saving file <b>$output</b>, size=".strlen($rs->fields[0])."<p>";
  69. $fd = fopen($output, "wb"); 
  70. fwrite($fd, $rs->fields[0]); 
  71. fclose($fd); 
  72.  
  73. print " <a href=file://$output>View Image</a>";
  74. //$rs = $conn->Execute('SELECT id,SUBSTRING(b1, 1, 10) FROM blobtest');
  75. //rs2html($rs);
  76. ?>